from dataclasses import dataclass

from src.application.order.converters import convert_order_entity_to_dto
from src.application.order.dto.order import OrderDTO
from src.application.order.uow import OrderUoW
from src.application.proxy.converters import convert_proxy_entity_to_dto
from src.application.proxy.dto.proxy import ProxyDTO
from src.domain.order.value_objects import OrderId


@dataclass(frozen=True)
class GetProxy:
    proxy_id: int


class GetProxyHanadler:
    """
    Получение прокси по id
    """

    def __init__(self, *, uow: OrderUoW) -> None:
        self._uow = uow

    async def __call__(self, command: GetProxy) -> ProxyDTO:
        proxy = await self._uow.proxy_repo.acquire_proxy_by_id(command.proxy_id)

        proxy_dto = convert_proxy_entity_to_dto(proxy)

        return proxy_dto
